package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicProGetApplyDAO;
import com.cssy.yd.logic.entity.LogicProGetApplyDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-08-12
 */
public class LogicProGetApplyDAOImpl extends SqlMapClientDaoSupport implements LogicProGetApplyDAO {

    /**
     * 插入数据
     * @param logicProGetApplyDO
     * @return 插入数据的主键
     */
    public String insertLogicProGetApplyDO(LogicProGetApplyDO logicProGetApplyDO) throws DataAccessException {
    	logicProGetApplyDO.setVarsion(1);
    	Object id = getSqlMapClientTemplate().insert("LogicProGetApply.insert", logicProGetApplyDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicProGetApplyDO
     * @return 查出的记录数
     */
    public Integer countLogicProGetApplyDOByExample(LogicProGetApplyDO logicProGetApplyDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProGetApply.countByDOExample", logicProGetApplyDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicProGetApplyDO
     * @return 受影响的行数
     */
    public Integer updateLogicProGetApplyDO(LogicProGetApplyDO logicProGetApplyDO) throws DataAccessException {
    	logicProGetApplyDO.setVarsionbt(logicProGetApplyDO.getVarsion());
    	logicProGetApplyDO.setVarsion(logicProGetApplyDO.getVarsion()+1);
    	int result = getSqlMapClientTemplate().update("LogicProGetApply.update", logicProGetApplyDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicProGetApplyDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicProGetApplyDO> findListByExample(LogicProGetApplyDO logicProGetApplyDO) throws DataAccessException {
        List<LogicProGetApplyDO> list = getSqlMapClientTemplate().queryForList("LogicProGetApply.findListByDO", logicProGetApplyDO);
        return list;
    }

    /**
     * 根据主键获取logicProGetApplyDO
     * @param id
     * @return logicProGetApplyDO
     */
    public LogicProGetApplyDO findLogicProGetApplyDOByPrimaryKey(String id) throws DataAccessException {
        LogicProGetApplyDO logicProGetApplyDO = (LogicProGetApplyDO) getSqlMapClientTemplate().queryForObject("LogicProGetApply.findByPrimaryKey", id);
        return logicProGetApplyDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicProGetApplyDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicProGetApply.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<LogicProGetApplyDO> find(SearchConditions scs)
			throws DataAccessException {
		List<LogicProGetApplyDO> list = getSqlMapClientTemplate().queryForList("LogicProGetApply_ex.find", scs);
		   return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicProGetApply_ex.count", scs);
	      return count;
	}

}